<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="redis" uri="http://www.shopjsp.com/redisTag/functions" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="basePath" value="${redis:getSysConfig('base_path_back')}"/>
<c:set var="uploadPath" value="${redis:getSysConfig('uploadFileVisitRoot')}"/>
<script type="text/javascript">

    /**
     * 查看结算明细
     */
    <shiro:hasPermission name="back_gotoShopSettlementDetailPage_settleDetail">
    function querySettlementOrders(){
        var selectedRow= $("#tt").bootstrapTable('getSelections');
        if(selectedRow.length==1){
            $("#btn_querySettlementOrders").attr("data-target", "#querySettlementOrdersModal");
            $("#settlementId").val(selectedRow[0].settlementId);
            $("#querySettlementOrdersModalLabel").empty().text("卖家未结算订单明细列表");
            $("#qform_sub")[0].reset();
            $("#tt_showSettlementOrdersList").bootstrapTable('refresh');
            showSettlementOrdersList();
        }else{
            $("#btn_querySettlementOrders").attr("data-target",""); /**没有选中记录不可打开模态框**/
            showMsg("请选择一行记录！");
        }
    }
    </shiro:hasPermission>

    /**
     * 查询商品列表
     */
    function showSettlementOrdersList(){
        var $tt_showSettlementOrdersList = $("#tt_showSettlementOrdersList").bootstrapTable({
            url: '${basePath}/back/shopSettlement/listSettlementOrdersBySettlementId.sjson',      	/**请求后台的URL（*）**/
            method: 'post',                       	/**请求方式（*）**/
            contentType: "application/x-www-form-urlencoded",
            dataType: 'json',
            toolbar: '#toolbar2',               	/**工具按钮用哪个容器**/
            striped: false,                      	/**是否显示行间隔色**/
            cache: false,                       	/**是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）**/
            pagination: true,                   	/**是否显示分页（*）**/
            sortable: false,                    	/**是否启用排序**/
            sortOrder: 'asc',                   	/**排序方式**/
            queryParamsType: '',
            sidePagination: 'server',           	/**分页方式：client客户端分页，server服务端分页（*）**/
            pageNumber: 1,
            pageSize:10,							/**初始化加载第一页，默认第一页**/
            pageList: [5,10, 25, 50],        	    /**可供选择的每页的行数（*）**/
            search: false,                       	/**是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大**/
            strictSearch: true,
            showColumns: true,                  	/**是否显示所有的列**/
            showRefresh: true,                  	/**是否显示刷新按钮**/
            minimumCountColumns: 2,             	/**最少允许的列数**/
            clickToSelect: true,                	/**是否启用点击选中行**/
            uniqueId: 'ordersId',                  /**每一行的唯一标识，一般为主键列**/
            singleSelect  : true,                   /** 单选checkbox**/
            showToggle:false,                    	/**是否显示详细视图和列表视图的切换按钮**/
            cardView: false,                    	/**是否显示详细视图**/
            detailView: false,                  	/**是否显示父子表**/
            columns: [
                {checkbox: true},
                {field: 'Number', title: '编号', align: 'center', valign: 'middle', width: '50px',
                    formatter: function (value, row, index) {
                        var page = $tt_showSettlementOrdersList.bootstrapTable("getPage");
                        return page.pageSize * (page.pageNumber - 1) + index + 1;
                    }
                },
                {field:"ordersNo",title:"订单号",align: 'center', valign: 'middle'},
                {field:"finalAmount",title:"订单营业额",align: 'center', valign: 'middle'},
                {field:"changeAmount",title:"订单财富券抵扣金额",align: 'center', valign: 'middle'},
                {field:"rakeAmount",title:"平台抽取营业额让利金额",align: 'center', valign: 'middle'},
                {field:"rebateAmount",title:"一级返利金额",align: 'center', valign: 'middle'},
                {field:"secRebateAmount",title:"二级返利金额",align: 'center', valign: 'middle'},
                {field:"thiRebateAmount",title:"三级返利金额",align: 'center', valign: 'middle'},
                {field:"ordersState",title:"订单状态",align: 'center', valign: 'middle',
                    formatter:function(value,row,index){
                        if(value==0){
                            return"生成订单";
                        }else if(value==3){
                            return"正在配货";
                        }else if(value==4){
                            return"已发货";
                        }else if(value==5){
                            return"确认收货";
                        }else if(value==6){
                            return"已取消";
                        }else if(value==7){
                            return"异常订单";
                        }else if(value==1){
                            return"<font color='#EE0000'>未付款</font>";
                        }else {
                            return"完成";
                        }
                    }
                },
                {field:"settlementStatus",title:"会员付款状态",align: 'center', valign: 'middle',
                    formatter:function(value,row,index){
                        if(value==0){
                            return"未付款";
                        }else if(value==1){
                            return"已付款";
                        }
                    }
                },
                {field:"changeAmountTotal",title:"退货返还财富券总金额",align: 'center', valign: 'middle'},
                {field:"returnAmountTotal",title:"退货返还总金额",align: 'center', valign: 'middle'}
            ],
            queryParams: function (params) {
                /**特别说明，返回的参数的值为空，则当前参数不会发送到服务器端,这种指定请求参数的方式和datatables控价类似**/
                params.ordersNo = $("#q_ordersNo").val();
                params.settlementId = $("#settlementId").val();
                params.currentPage = params.pageNumber;
                return params;
            }
        });

        $(function(){
            /**表单查询**/
            $("#btn_query_sub").click(function () {
                $("#tt_showSettlementOrdersList").bootstrapTable('refresh');
            });
        });

    }

</script>
<!--模态框（Modal） -->
<div class="modal fade" id="querySettlementOrdersModal" tabindex="-1" role="dialog" aria-labelledby="querySettlementOrdersModalLabel" aria-hidden="true" data-backdrop="static">
    <div class="modal-dialog" style="width:90%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h5 class="modal-title" id="querySettlementOrdersModalLabel"></h5>
            </div>

            <div class="modal-body" style="padding-top: 5px;">
                <!-- 查询条件 -->
                <div class="panel panel-default" style="margin-top: 15px;">
                    <div class="panel-body">
                        <form id="qform_sub" class="form-horizontal">
                            <div class="form-group" style="margin-top:15px">
                                <div class="col-sm-3">
                                    <div class="input-group input-group-sm">
                                        <span class="input-group-addon">订单号</span>
                                        <input type="text" class="form-control" id="q_ordersNo" name="ordersNo" placeholder="请输入订单号"/>
                                    </div>
                                </div>
                                <div class="col-sm-2" style="width:160px;">
                                    <button type="button" id="btn_query_sub" class="btn btn-primary">查询</button>&nbsp;&nbsp;
                                    <button type="reset" class="btn btn-success" id="resetBtn" >重置</button>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>

                <!-- 工具栏 -->
                <div id="toolbar2" class="btn-group">
                    <button id="btn_export" type="button" class="btn btn-default" data-toggle="modal" onclick="">
                        <span class="glyphicon glyphicon-export" aria-hidden="true"></span>导出报表
                    </button>
                </div>

                <!-- 渲染的table -->
                <table id="tt_showSettlementOrdersList"></table>
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>